var express = require('express');
var vhost = require('vhost')
var app = express();
// var bodyParser = require('body-parser');
// var multer  = require('multer');

app.use(express.static('public'));
// app.use(bodyParser.urlencoded({ extended: false }));
// app.use(multer({ dest: '/tmp/'}).array('image'));
// app.use("/static",express.static("./public"));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');

// app.get('/', function (req, res) {
//     res.send('Hello World!');
// });

app.get('/', function (req, res) {
    res.sendFile( __dirname + "/" + "index.html" );
})
app.get('/json', function (req, res) {
    // 输出 JSON 格式
    var response = {
        "first_name":'jack',
        "last_name":'tom'
    };
    res.end(JSON.stringify(response));
})
app.get('*', function(req, res){
    res.render('404', {
        title: 'No Found'
    })
});
var server = app.listen(80, function () {
    var host = server.address().address;
    var port = server.address().port;

    console.log('Example app listening at http://%s:%s', host, port);
});